package com.bobo.service.impl;

import java.text.DecimalFormat;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.bobo.mapper.HandleMapper;
import com.bobo.mapper.UserMapper;
import com.bobo.services.HandleService;
import com.bobo.vo.Page;
import com.bobo.vo.Product;
import com.bobo.vo.Sale;
import com.bobo.vo.User;
import com.bobo.vo.extension.CityProductProfit;
import com.bobo.vo.extension.Extension;
import com.bobo.vo.extension.ProductListExtension;
import com.bobo.vo.extension.ProductSaleExtension;
@Component
@Scope("prototype")
public class HandleServiceImpl implements HandleService {
	@Resource
	private UserMapper userMapper;
	@Resource
	private HandleMapper handleMapper;
	@Override
	public boolean inserted(User user) {
		return userMapper.insertUser(user);
	}
	@Override
	public boolean inserteProduct(Product product) {
		return userMapper.insertProduct(product);
	}
	@Override
	public boolean inserteSale(Sale sale) {
		return userMapper.insertSale(sale);
	}
	@Override
	public boolean insertUserBatch(List<User> users) {
		return userMapper.insertUserBatch(users);
	}
	@Override
	public boolean insertSaleBatch(List<Sale> sales) {
		return userMapper.insertSaleBatch(sales);
	}
	@Override
	public boolean insertProductBatch(List<Product> products) {
		return userMapper.insertProductBatch(products);
	}
	@Override
	public List<User> findUserAll() {
		return handleMapper.findUserAll();
	}
	//找出某位用户购买商品清单
	@Override
	public List<Extension> findUserBuyList(int id) {
		return handleMapper.findUserBuyList(id);
	}
	@Override
	public List<ProductSaleExtension> findProductList() {
		return handleMapper.findProductList();
	}
	
	
	@Override
	public List<Extension> findProductBuyDetail(int productId) {
		return handleMapper.findProductBuyDetail(productId);
	}
	@Override
	public List<User> findCityList() {
		return handleMapper.findCityList();
	}
	@Override
	public List<CityProductProfit> findCityProductProfitList(String address) {
		return handleMapper.findCityProductProfitList(address);
	}
	@Override
	public List<ProductListExtension> findCityProductProfitList2(int page) {
		Page page2 = new Page();
		page2.setBegin((page-1)*100 + 2000);
		page2.setEnd((page-1)*100 + 2000 + 100);
		return handleMapper.findCityProductProfitList2(page2);
	}
	
	@Override
	public Integer findProductNum_service() {
		return handleMapper.findProductNum();
	}
	@Override
	public List<CityProductProfit> findCityProductProfitListLastMonthService(
			String address) {
		return handleMapper.findCityProductProfitListLastMonth(address);
	}
	

}
